home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / DEV / C-H / Finder Progress Pascal.cpt / Finder Progress Pascal / Finder Progress.p next >
Text File  |  1993-01-03  |  2KB  |  77 lines

  1. program FinderProgress;
  2.  
  3. {    Finder Progress }
  4.  
  5. {    by Joe Zobkiw}
  6.  
  7. {    This is a simple THINK Pascal 4.0.1 project and compiled application }
  8. {    that shows you how to (very easily) implement a Finder 7-like }
  9. {    progress meter. I have only seen cheap imitations on the nets so }
  10. {    I decided to code one that looks a little closer to how the Finder }
  11. {    does. }
  12.  
  13. {    You can extend this code in any way you wish, make it movable modal, }
  14. {    do with it what you will, it should work in almost any scenario. }
  15.  
  16. {    If you make any changes please send them to me at any of the }
  17. {    following addresses. Enjoy, and please give this to your friends. }
  18.  
  19. {    America Online: AFL Zobkiw}
  20. {    Internet: zobkiw@world.std.com}
  21.  
  22. {    Pascal translation by Mike Epstein (America Online: MEpstein, Internet: mepstein@aol.com)}
  23.  
  24.     uses
  25.         Routines;
  26.     var
  27.         d: DialogPtr;
  28.         savePort: GrafPtr;
  29.         R: Rect;
  30.         i: Integer;
  31.         theDepth: Integer;
  32.         someTime: LongInt;
  33.         itemHit: Integer;
  34.  
  35. begin
  36.     SetCursor(arrow);
  37.     GetDateTime(randSeed);
  38.     FlushEvents(everyEvent, 0);
  39.     DrawMenuBar;
  40.  
  41.    {show the about alert}
  42.     itemHit := Alert(kAboutAlertID, nil);
  43.  
  44.    {get the dialog box}
  45.     d := GetNewDialog(kModalProgressDialogID, nil, WindowPtr(-1));
  46.     if d = nil then
  47.         ExitToShell;
  48.  
  49.    {set up the port for drawing}
  50.     GetPort(savePort);
  51.     SetPort(d);
  52.  
  53.     ParamText('Now doing something time consuming…', '', '', '');
  54.  
  55.     ShowWindow(d);
  56.     DrawDialog(d);
  57.  
  58.    {if this isn’t available, we are toast anyway!}
  59.     SetCursor(GetCursor(watchCursor)^^);
  60.  
  61.    {get the rectangle of the progress item and the current bitdepth}
  62.     r := DItemRect(d, kDialogProgressItem);
  63.     theDepth := BitDepth;
  64.  
  65.    {now we’re making progress!}
  66.     for i := 1 to 100 do
  67.         begin
  68.             UpdateProgress(r, i, (bitDepth >= kColorBitDepth));
  69.             Delay(2, someTime);
  70.         end;
  71.  
  72.    {clean things up}
  73.     InitCursor;
  74.     ParamText('', '', '', '');
  75.     DisposeDialog(d);
  76.     SetPort(savePort);
  77. end.